#include <iostream>
#include <string>
#include <fstream>
using namespace std;

//transform matrix with 2*3 
struct Homat2D
{
    double A;
    double B;
    double C;
    double D;
    double E;
    double F;
};

// float / point
struct Point2F
{
    float x;
    float y;
};

//function 1: load transform matrix,only use in init
//pMatrix:matrix pointer
bool loadMatrix(Homat2D* pMatrix,string fileName = "matrix.dat")
{
    ifstream in;
    in.open(fileName,ios_base::in);
    if(!in.is_open())
    {
        //文件打开失败，不存在
        return false;
    }
    in >> pMatrix->A;
    in >> pMatrix->B;
    in >> pMatrix->C;
    in >> pMatrix->D;
    in >> pMatrix->E;
    in >> pMatrix->F;
    in.close();
    return true;
}

//function 2: trans 2d point
Point2F affineTrans2DPoint(Homat2D matrix, Point2F point)
{
    Point2F transPoint;
    transPoint.x= matrix.A * point.x + matrix.B * point.y + matrix.C;
    transPoint.y= matrix.D * point.x + matrix.E * point.y + matrix.F;
    return transPoint;
}
